Function Reference

_AD_GetManager

Retrieves all users that are managed by any or the specified user.

#Include <AD.au3>
_AD_GetManager([$sManager = "*"])

 

Parameters

$sManager Optional: Manager to filter the list of users (default = *). Can be sAMAccountName or FQDN

 

Return Value

Success: Returns a one-based two dimensional array with the following information:
    0 - distinguished name of the user
    1 - distinguished name of the manager for this user
Failure: "", sets @error to:
    1 - $sManager is unknown
    2 - No users found. @extended is set to the error returned by LDAP

 

Remarks

This query returns all users that have the attribute "Manager" set or set to the specified manager.

To get a list of all users that manager x manages (by querying just the user object) use:
$Result = _AD_GetObjectAttribute("samAccountName of the manager","directReports")
_ArrayDisplay($Result)

 

Related

 

Example


#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include <AD.au3>

; Open Connection to the Active Directory
_AD_Open()
If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)

Global $aManager[1][2]
Global $bNotFound = False
; *****************************************************************************
; Example 1
; Get a list of users that have the attribute "manager" set
; *****************************************************************************
$aManager = _AD_GetManager()
If @error > 0 Then
    MsgBox(64, "Active Directory Functions - Example 1", "No managed users could be found")
    $bNotFound = True
Else
    _ArrayDisplay($aManager, "Active Directory Functions - Example 1 - managed users")
EndIf

; *****************************************************************************
; Example 2
; Get a list of users that are managed by the first manager found in example 1
; *****************************************************************************
If $bNotFound Then
    MsgBox(64, "Active Directory Functions - Example 2", "Can't run example 2 because example 1 returned no data")
    Exit
EndIf
Global $Result = _AD_GetObjectAttribute(_AD_FQDNToSamAccountName($aManager[1][1]), "directReports")
_ArrayDisplay($Result, "Active Directory Functions - Example 2 - users managed by '" & $aManager[1][1] & "'")

; Close Connection to the Active Directory
_AD_Close()